package com.jeesite.modules.kj.api.controller.activity;


import com.jeesite.common.collect.ListUtils;
import com.jeesite.modules.kj.api.vo.response.CityResponseVo;
import com.jeesite.modules.kj.api.vo.responseVo.ResponseBean;
import com.jeesite.modules.kj.entity.KjCity;
import com.jeesite.modules.kj.service.KjCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Author:hzy
 * Date:2021/07/04
 * Description:
 */
@Api(value = "城市api", tags = {"城市API"})
@Slf4j
@Controller
@RequestMapping(value = "/api/city")
public class CityApiController {
    private final static Logger logger = LoggerFactory.getLogger(CityApiController.class);

    @Autowired
    private KjCityService kjCityService;

    @ApiOperation(value = "获取城市列表", notes = "获取城市列表")
    @GetMapping(value = "list")
    public ResponseBean<List<CityResponseVo>> list() {
        List<KjCity> cityList = kjCityService.findList(new KjCity());
        List<CityResponseVo> vos = ListUtils.newArrayList();
        for (KjCity city: cityList
             ) {
            vos.add(new CityResponseVo(city));
        }
        return new ResponseBean<>(vos);
    }


}
